from framework.base_page import BasePage
from selenium.webdriver.common.by import By
from framework.public_class import *


class ShouyePage(BasePage):
    """首页相关操作"""

    # 从搜索页返回首页
    def back_to_shouye(self):
        current_url = self.current_url()  # 获取当前url
        sort_url = con.get_config(section="test_config", key="sort_url")
        if sort_url in current_url:  # 当前url在分类界面
            self.back()

    def input_search_key(self, search_key):
        """输入搜索关键字"""
        self.input_text(selector="id=>J_searchKeywords", text=search_key)

    def click_pindao(self, selector):
        """点击频道"""
        self.element_click(selector=selector)

    # 等待第一个漫画显示出来
    def wait_first_comic_is_visible(self):
        return self.is_visible(locator=(By.CLASS_NAME, "acgn-thumbnail"))  # 首页的频道肯定有漫画，所以判断有无漫画即可
